package com.sunday.common.core.remoting.base.page;

import com.sunday.common.core.utils.ReflectToJsonUtils;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 分页查询结果 DTO
 *
 * @author zsy
 * @since 2022/10/14
 */
@Slf4j
@Data
@NoArgsConstructor
public class PageResultDTO<T> extends BasePage<T> {

    /**
     * 分页构造函数
     *
     * @param current  当前页
     * @param pageSize 每页显示条数
     */
    public PageResultDTO(long current, long pageSize) {
        super(current, pageSize);
    }

    public PageResultDTO(long current, long pageSize, long total) {
        super(current, pageSize, total);
    }

    /* --------------- 以下为静态构造方式 --------------- */
    public static <T> PageResultDTO<T> of(long current, long pageSize) {
        return of(current, pageSize, 0);
    }

    public static <T> PageResultDTO<T> of(long current, long pageSize, long total) {
        return new PageResultDTO<T>(current, pageSize, total);
    }

    @Override
    public String toString() {
        return ReflectToJsonUtils.toJson(this);
    }
}
